<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <script type="text/javascript" src="js/jquery2.js"></script>
    <script type="text/javascript" src="js/jquery2.sorted.js"></script>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="js/ckform.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/jquerypicture.js"></script>
    <script type="text/javascript" charset="utf-8" src="utf8-jsp/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="utf8-jsp/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="utf8-jsp/lang/zh-cn/zh-cn.js"></script>
	<%--提示消息插件--%>
    <script src="js/Dream-Msg/lib/dream-msg.min.js"></script>
    <script>
        //添加博客
        function addBlog(){
            $.post("blog/addBlog",$("#formId").serialize(),function (result) {
                if(result.status == 1){
                    //添加成功
                    Dreamer.success(result.message)
                    window.setTimeout(function () {
                        window.location.href = "blog_list.jsp"
                    },1500)
                }else if(result.status == -1){
                    //添加失败
                    Dreamer.error(result.message,1000)
                }else if(result.status == -2){
                    //未登录
                    Dreamer.error(result.message,1000)
                    //跳转到登录页面
                    window.open("login.jsp","_top")
                }
            })
        }

        //查询一级类别
        $(function () {
            $.post("btype/getBigType",null,function (result) {
                // alert(JSON.stringify(result))
                let btylist='<option value="0">==请选择大类==</option><br>';
                result.forEach(function (btype) {
                    btylist += `<option value="\${btype.typeid}">\${btype.typename}</option><br>`;
                });
                $("#oneTypeId").html(btylist)
            })
        })

        //获取二级类别
        function getBtype(typeid) {
            // alert(typeid)
            $.post("btype/getsType","typeId="+typeid,function (result) {
                // alert(JSON.stringify(result))
                let btylist='';
                result.forEach(function (btype) {
                    btylist += `<option value="\${btype.typeid}">\${btype.typename}</option><br>`;
                });
                $("#twoTypeId").append(btylist)
            })
        }

    </script>
    <script type="application/javascript">

        var ue = UE.getEditor('editor');

        function commit(){
            $("#form3").submit();
        }
    </script>
    <style type="text/css">
        body {font-size: 20px;
            padding-bottom: 40px;
            background-color:#e9e7ef;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
</head>
<body>
<input type="hidden" name="typeid" id="typeId">
<form action="#" method="post" id="formId" class="definewidth m20" enctype="multipart/form-data">
<table class="table table-bordered table-hover m10" style="margin-left:10px;margin-top:3px;">
    <tr>
        <td width="10%" class="tableleft">类别</td>
        <td>
            <select name="bigTypeId" id="oneTypeId"  onchange="getBtype($(this).val())">

            </select>
            <select name="typeFk" id="twoTypeId" onchange="getStype($(this).val())">
                <option value="0">==请选择小类==</option>
            </select>
        </td>
    </tr>
    
   
    <tr>
        <td class="tableleft">博客标题</td>
        <td><input type="text" name="btitle"/></td>
    </tr>
    <tr>
        <td class="tableleft">博客内容</td>
        <td>
            <script id="editor" name="bcontent" type="text/plain" style="width:1024px;height:300px;"></script>
        </td>
    </tr>

    <tr>
        <td class="tableleft"></td>
        <td>
            <button style="margin-left:5px;"type="button" id="subBtn" class="btn btn-primary" onclick="addBlog()" >保存</button> &nbsp;
            &nbsp;
            <button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
        </td>
    </tr>
</table>
</form>

</body>
</html>

